home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_qt.idb / usr / freeware / include / Qt / qgvector.h.z / qgvector.h
Encoding:
C/C++ Source or Header  |  1998-10-28  |  3.1 KB  |  99 lines

  1. /****************************************************************************
  2. ** $Id: qgvector.h,v 2.4 1998/07/03 00:09:46 hanord Exp $
  3. **
  4. ** Definition of QGVector class
  5. **
  6. ** Created : 930907
  7. **
  8. ** Copyright (C) 1992-1998 Troll Tech AS.  All rights reserved.
  9. **
  10. ** This file is part of Qt Free Edition, version 1.40.
  11. **
  12. ** See the file LICENSE included in the distribution for the usage
  13. ** and distribution terms, or http://www.troll.no/free-license.html.
  14. **
  15. ** IMPORTANT NOTE: You may NOT copy this file or any part of it into
  16. ** your own programs or libraries.
  17. **
  18. ** Please see http://www.troll.no/pricing.html for information about 
  19. ** Qt Professional Edition, which is this same library but with a
  20. ** license which allows creation of commercial/proprietary software.
  21. **
  22. *****************************************************************************/
  23.  
  24. #ifndef QGVECTOR_H
  25. #define QGVECTOR_H
  26.  
  27. #ifndef QT_H
  28. #include "qcollection.h"
  29. #endif // QT_H
  30.  
  31.  
  32. class QGVector : public QCollection        // generic vector
  33. {
  34. friend class QGList;                // needed by QGList::toVector
  35. public:
  36.     QDataStream &read( QDataStream & );        // read vector from stream
  37.     QDataStream &write( QDataStream & ) const;    // write vector to stream
  38.  
  39.     virtual int compareItems( GCI, GCI );
  40.  
  41. protected:
  42.     QGVector();                    // create empty vector
  43.     QGVector( uint size );            // create vector with nullptrs
  44.     QGVector( const QGVector &v );        // make copy of other vector
  45.    ~QGVector();
  46.  
  47.     QGVector &operator=( const QGVector &v );    // assign from other vector
  48.  
  49.     GCI     *data()    const    { return vec; }
  50.     uint  size()    const    { return len; }
  51.     uint  count()   const    { return numItems; }
  52.  
  53.     bool  insert( uint index, GCI );        // insert item at index
  54.     bool  remove( uint index );            // remove item
  55.     GCI      take( uint index );            // take out item
  56.  
  57.     void  clear();                // clear vector
  58.     bool  resize( uint newsize );        // resize vector
  59.  
  60.     bool  fill( GCI, int flen );        // resize and fill vector
  61.  
  62.     void  sort();                // sort vector
  63.     int      bsearch( GCI ) const;            // binary search (when sorted)
  64.  
  65.     int      findRef( GCI, uint index ) const;    // find exact item in vector
  66.     int      find( GCI, uint index ) const;    // find equal item in vector
  67.     uint  containsRef( GCI ) const;        // get number of exact matches
  68.     uint  contains( GCI ) const;        // get number of equal matches
  69.  
  70.     GCI      at( uint index ) const
  71. #if defined(CHECK_RANGE) || defined(QGVECTOR_CPP)
  72.     ;                    // safe (impl. in qcvector.cpp)
  73. #else
  74.     { return vec[index]; }            // fast
  75. #endif
  76.     bool insertExpand( uint index, GCI );    // insert, expand if necessary
  77.  
  78.     void toList( QGList * ) const;        // put items in list
  79.  
  80.     virtual QDataStream &read( QDataStream &, GCI & );
  81.     virtual QDataStream &write( QDataStream &, GCI ) const;
  82.  
  83. private:
  84.     GCI     *vec;
  85.     uint  len;
  86.     uint  numItems;
  87. };
  88.  
  89.  
  90. /*****************************************************************************
  91.   QGVector stream functions
  92.  *****************************************************************************/
  93.  
  94. QDataStream &operator>>( QDataStream &, QGVector & );
  95. QDataStream &operator<<( QDataStream &, const QGVector & );
  96.  
  97.  
  98. #endif // QGVECTOR_H
  99.